//
//  SetAccountInformationVC.m
//  SelfDriving
//
//  Created by apple on 16/1/17.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "SetAccountInformationVC.h"
#import "BusinessService+User.h"
@interface SetAccountInformationVC ()
@property (weak, nonatomic) IBOutlet UITextField *nameField;
@property (weak, nonatomic) IBOutlet UITextField *accountField;

@end

@implementation SetAccountInformationVC

- (void)viewDidLoad {
    [super viewDidLoad];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}

- (IBAction)submitAction:(UIButton *)sender {
    if ([_nameField.text trim].length == 0) {
        [SVProgressHUD showErrorWithStatus:@"请输入支付宝姓名"];
        return;
    }
    if ([_accountField.text trim].length == 0) {
        [SVProgressHUD showErrorWithStatus:@"请输入支付宝账号"];
        return;
    }
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:[_nameField.text trim] forKey:@"name"];
    [dic setObject:[_accountField.text trim] forKey:@"account"];
    [[BusinessService shareInstance]setAlipayAccount:dic success:^(id result) {
        [SVProgressHUD showSuccessWithStatus:@"设置成功"];
        [_delagete delAlipayAccount];
        [[AppDelegate shareDelegate]refdata:^(id a) {
            [self.navigationController popViewControllerAnimated:YES];
        }];
    } failure:^(id result) {
        [SVProgressHUD showErrorWithStatus:result];
    }];
    
}
- (IBAction)backActino:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
